﻿using System;
using System.Collections.Generic;
using System.Linq;

using System.Text;

using Microsoft.Xna.Framework;


namespace SimNations.Pathfinding
{
    public class Square
    {
        // MEMBER VARIABLES
        // ------------------------------------------------------------------------------------------------------------------------

        int m_GScore;   // Total movement cost to move from the starting square to this quare
        int m_HScore;   // Estimated total movement cost to move from this square to the end square
        int m_FScore;   // Overall score based on the G and H scores.

        Square m_ParentSquare = null;

        Vector2 m_Position;


        // CONSTRUCTORS
        // ------------------------------------------------------------------------------------------------------------------------

        public Square()
        {
        } // end Square::Square()

        public Square(Vector2 position)
        {
            m_Position = position;

        } // end Square::Square(Vector2)

        public Square(float X, float Y)
        {
            m_Position.X = X;
            m_Position.Y = Y;

        } // end Square::Square(int, int)


        // PRIVATE/PROTECTED METHODS
        // ------------------------------------------------------------------------------------------------------------------------



        // METHODS
        // ------------------------------------------------------------------------------------------------------------------------

        // Returns true if the specified square is diagonal from this square, or false otherwise.
        public bool IsDiagonal(Square square)
        {
            if (!(this.Position.X == square.Position.X ||
                  this.Position.Y == square.Position.Y))
                return true;
            else
                return false;

        } // end Square::IsDiagonal(Square)

        // Returns true if the specified square is diagonal from this square, or false otherwise.
        public bool IsDiagonal(Vector2 square)
        {
            if (!(this.Position.X == square.X ||
                  this.Position.Y == square.Y))
                return true;
            else
                return false;

        } // end Square::IsDiagonal(Vector2)

        // Returns true if the specified square is orthogonal (non diagonal) from this square, or false otherwise.
        public bool IsOrthogonal(Square square)
        {
            if (this.Position.X == square.Position.X ||
                this.Position.Y == square.Position.Y)
                return true;
            else
                return false;

        } // end Square::IsOrthogonal(Square)

        // Returns true if the specified square is orthogonal (non diagonal) from this square, or false otherwise.
        public bool IsOrthogonal(Vector2 square)
        {
            if (this.Position.X == square.X ||
                this.Position.Y == square.Y)
                return true;
            else
                return false;

        } // end Square::IsOrthogonal(Square)



        // DEBUG METHODS
        // ------------------------------------------------------------------------------------------------------------------------

#if (DEBUG)
        // put all debug methods in here...
#endif



        // PROPERTIES
        // ------------------------------------------------------------------------------------------------------------------------

        public int G_Score
        {
            get
            {
                return m_GScore;
            }
            set
            {
                m_GScore = value;
            }
        } // end property G_Score

        public int H_Score
        {
            get
            {
                return m_HScore;
            }
            set
            {
                m_HScore = value;
            }
        } // end property H_Score

        public int F_Score
        {
            get
            {
                return m_FScore;
            }
            set
            {
                m_FScore = value;
            }
        } // end property F_Score

        public Square ParentSquare
        {
            get
            {
                return m_ParentSquare;
            }
            set
            {
                m_ParentSquare = value;
            }
        } // end property ParentSquare

        public Vector2 Position
        {
            get
            {
                return m_Position;
            }
            set
            {
                m_Position = value;
            }
        } // end property Position



        // EVENTS
        // ------------------------------------------------------------------------------------------------------------------------


    } // end class Square

}
